<?php

namespace Admin\Models\crm;

class XhcustTrack extends basicModel
{

    /**
     *
     * @var integer
     * @Primary
     * @Identity
     * @Column(type="integer", length=11, nullable=false)
     */
    public $iCUTId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iCUId;

    /**
     *
     * @var integer
     * @Column(type="integer", length=11, nullable=true)
     */
    public $iTrackType;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tTrackTime;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $iGrade;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $iChargeMode;
    public $iUsageMode;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $iLevel;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sStatus;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sImages;

    public $sFiles;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sRetain2;

    /**
     *
     * @var string
     * @Column(type="string", length=255, nullable=true)
     */
    public $sRetain3;

    /**
     *
     * @var integer
     * @Column(type="integer", length=1, nullable=true)
     */
    public $bDelete;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tCreateDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     * @Column(type="string", nullable=true)
     */
    public $tLastModifyDate;

    /**
     *
     * @var integer
     * @Column(type="integer", length=20, nullable=true)
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
//        $this->setSchema("customer");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHCust_Track';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhcustTrack[]|XhcustTrack
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return XhcustTrack
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     *  获取意向情况配置项
     *
     * @param $ids
     * @return array
     *
     */
    public static function findDataArrayByIds($ids){
        if(!$ids){
            return [];
        }
        $objs=XhcustTrack::find([
            'columns'   =>'iCUTId,iGrade,iLevel,iChargeMode,iUsageMode,sYear',
            'conditions' => 'iCUTId in ({ids:array})',
            'bind' => ['ids' => $ids]
        ]);
        if(!$objs){
            return [];
        }
        $arrayData=$objs->toArray();
        $arrayData=array_column($arrayData,null,'iCUTId');
        return $arrayData;
    }

    public function afterFetch()
    {
        $this->tTrackTime=date('Y-m-d',strtotime($this->tTrackTime));

    }

}
